{
  "$schema": "http://json-schema.org/draft-07/schema",
  "$id": "common",
  "type": "object",
  "description": "Common definitions to import from other schemas",
  "definitions": {
    "reference": {
      "$id": "#reference",
      "type": "object",
      "description": "A reference by name to another entity.",
      "required": ["kind", "namespace", "name"],
      "additionalProperties": false,
      "properties": {
        "kind": {
          "type": "string",
          "description": "The kind field of the entity.",
          "minLength": 1
        },
        "namespace": {
          "type": "string",
          "description": "The metadata.namespace field of the entity.",
          "minLength": 1
        },
        "name": {
          "type": "string",
          "description": "The metadata.name field of the entity.",
          "minLength": 1
        }
      }
    },
    "relation": {
      "$id": "#relation",
      "type": "object",
      "description": "A directed relation from one entity to another.",
      "required": ["type", "targetRef"],
      "additionalProperties": false,
      "properties": {
        "type": {
          "type": "string",
          "minLength": 1,
          "pattern": "^\\w+$",
          "description": "The type of relation."
        },
        "target": {
          "$ref": "#reference",
          "deprecated": true
        },
        "targetRef": {
          "type": "string",
          "minLength": 1,
          "description": "The entity ref of the target of this relation."
        }
      }
    },
    "status": {
      "$id": "#status",
      "type": "object",
      "description": "The current status of the entity, as claimed by various sources.",
      "required": [],
      "additionalProperties": true,
      "properties": {
        "items": {
          "type": "array",
          "items": {
            "$ref": "#statusItem"
          }
        }
      }
    },
    "statusItem": {
      "$id": "#statusItem",
      "type": "object",
      "description": "A specific status item on a well known format.",
      "required": ["type", "level", "message"],
      "additionalProperties": true,
      "properties": {
        "type": {
          "type": "string",
          "minLength": 1
        },
        "level": {
          "$ref": "#statusLevel",
          "description": "The status level / severity of the status item."
        },
        "message": {
          "type": "string",
          "description": "A brief message describing the status, intended for human consumption."
        },
        "error": {
          "$ref": "#error",
          "description": "An optional serialized error object related to the status."
        }
      }
    },
    "statusLevel": {
      "$id": "#statusLevel",
      "type": "string",
      "description": "A status level / severity.",
      "enum": ["info", "warning", "error"]
    },
    "error": {
      "$id": "#error",
      "type": "object",
      "description": "A serialized error object.",
      "required": ["name", "message"],
      "additionalProperties": true,
      "properties": {
        "name": {
          "type": "string",
          "examples": ["Error", "InputError"],
          "description": "The type name of the error",
          "minLength": 1
        },
        "message": {
          "type": "string",
          "description": "The message of the error"
        },
        "code": {
          "type": "string",
          "description": "An error code associated with the error"
        },
        "stack": {
          "type": "string",
          "description": "An error stack trace"
        }
      }
    }
  }
}
